package com.example.demo.controller;
import com.example.demo.model.Xj;
import com.example.demo.service.IXjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator 董婷
 */

@Api(tags = "销假管理")
@RestController
@RequestMapping("/swagger25")
public class xjController {
    @Autowired
    private IXjService xjService;
    @CrossOrigin
    @ApiOperation(value="对销假信息的添加方法")
    @PostMapping("/insertxj")
    public int insertOb(@RequestBody Xj xj){
        System.out.println("进入添加销假信息接口" );
        return xjService.insertXj(xj);
    }

    @PostMapping("/getAll")
    public List<Xj> getAllOb(@RequestBody Xj xj)
    {
        System.out.println("进入查询销假信息方法");
        List<Xj> listXj=xjService.getAllXj(xj);
        return listXj;
    }
    @PostMapping("/editXj")
    public int EditXj(@RequestBody Xj xj){
        System.out.println("添加修改销假信息方法");
        return xjService.updateXj(xj);
    }
    @GetMapping("/delXj")
    public int Delete(int xjid){
        System.out.println("进入删除销假信息方法");
        int returnValues=0;
        if(xjid!=0){
            Xj xj=new Xj();
            xj.setObid(xjid);
            returnValues=xjService.deleteXj(xj);
        }
        return returnValues;
    }

    @GetMapping("/getOne")
    public Xj getXj(int xjid){
        Xj xj=new Xj();
        System.out.println("进入单条查询销假信息方法");
        if(xjid!=0){
            Xj xj1=new Xj();
            xj1.setXjid(xjid);
            xj=xjService.getXj(xj1);
            System.out.println("返回的数据集合为:"+xj.getXjid());
        }
        return xj;
    }








}
